package sis.studentinfo;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Date;


/**
 * 代表某个大学单学期的课程
 * @author keliangliang
 *
 */
public class CourseSession extends Session{

	
	private String department;
	private String number;
	private ArrayList<Student> allStudents = new ArrayList<Student>();
	private Date startDate;
	private int numberOfCredits;
	private URL url;
	private static int count;
	/**
	 * 
	 * @param department 
	 * @param number   
	 * @param startDate 
	 */
	protected CourseSession(Course course, Date startDate) {
		super(course,startDate);
	}
	private static void incrementCount() {
		count++;
	}

	public static void resetCount() {
		count = 0;
		
	}
	public static int getCount() {
		return count;
	}
	public static CourseSession create(Course course,Date startDate){
		incrementCount();
		return new CourseSession(course, startDate);
	}
	
	protected int getSessionLength() {
		return 16;
	}
	public void setUrl(String urlString) throws SessionException {
		try {
			this.url = new URL(urlString);
		} catch (MalformedURLException e) {
			log(e);
			throw new SessionException(e);
		}
		
	}
	private void log(MalformedURLException e) {
		e.printStackTrace();
	}
	public URL getUrl() {
		return url;
	}
}
